package com.cz.kingdee.prod;

import com.cz.kingdee.KingdeeClient;
import com.cz.kingdee.dto.PrdInstock;
import com.kingdee.bos.webapi.entity.QueryParam;
import com.kingdee.bos.webapi.sdk.K3CloudApi;

import java.util.HashMap;
import java.util.List;

public class PrdInstockQuery {
    public static void main(String[] args) throws Exception {

        KingdeeClient client = new KingdeeClient();
        K3CloudApi k3CloudApi = client.getProdKingdeeClient();
        QueryParam queryParam = new QueryParam();
        queryParam.setFormId("PRD_INSTOCK");
        queryParam.setFieldKeys("FMaterialId,FMaterialName,FBillNo,FDate,FMoBillNo,FMoId,FMoEntryId,FRealQty,F_ora_XSDDH,FMoEntrySeq,FMaterialId.FNumber,FApproveDate,FPrdOrgId.FName,FWorkShopId1.FName,FStockId.FName");
        //FA
        //queryParam.setFilterString("FPrdOrgId = '100034' and FWorkShopId1 = '2539006' and  FDate >= '2025-01-01 00:00:00'  and FDate < '2025-02-01 00:00:00'" + " and FDocumentStatus = 'C'");

        queryParam.setFilterString("FBillNo = 'SCRKCZ25135072'");

        HashMap<String, String> map = new HashMap<>();
        List<PrdInstock> prdInstockList = k3CloudApi.executeBillQuery(queryParam, PrdInstock.class);
        for (PrdInstock prdInstock : prdInstockList) {
            String fMoBillNo = prdInstock.getFMoBillNo();
            String line = prdInstock.getFMoEntrySeq();
            String key = fMoBillNo + "-" + line;
            map.put(key, prdInstock.getFMaterialName());
        }
        System.out.println("FA 生产入库单的物料数量:"+map.size());
    }
}
